package com.kensure.shike.baobei.service;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import co.kensure.frame.JSBaseService;

import com.kensure.shike.baobei.dao.SKBaobeiDetailDao;
import com.kensure.shike.baobei.model.SKBaobei;
import com.kensure.shike.baobei.model.SKBaobeiDetail;


/**
 * 宝贝详情服务实现类
 * @author fankd created on 2019-6-16
 * @since 
 */
@Service
public class SKBaobeiDetailService extends JSBaseService{
	
	@Resource
	private SKBaobeiDetailDao dao;
    
    
    public SKBaobeiDetail selectOne(Long id){
    	return dao.selectOne(id);
    }
	
	public List<SKBaobeiDetail> selectByIds(Collection<Long> ids){
		return dao.selectByIds(ids);
	}
	
	public List<SKBaobeiDetail> selectAll(){
		return dao.selectAll();
	}
	
	public List<SKBaobeiDetail> selectByWhere(Map<String, Object> parameters){
		return dao.selectByWhere(parameters);
	}
	
	public long selectCount(){
		return dao.selectCount();
	}
	
	public long selectCountByWhere(Map<String, Object> parameters){
		return dao.selectCountByWhere(parameters);
	}
	
	
	public boolean insert(SKBaobeiDetail obj){
		super.beforeInsert(obj);
		return dao.insert(obj);
	}
	
	public boolean update(SKBaobeiDetail obj){
		return dao.update(obj);
	}
    
    public boolean updateByMap(Map<String, Object> params){
		return dao.updateByMap(params);
	}
    
    
	public boolean delete(Long id){
		return dao.delete(id);
	}	
	
    public boolean deleteMulti(Collection<Long> ids){
		return dao.deleteMulti(ids);
	}
    
    public boolean deleteByWhere(Map<String, Object> parameters){
		return dao.deleteByWhere(parameters);
	}
    
    public void add(SKBaobei baobei) {
		// 删除老的
    	delete(baobei.getId());
		// 插入新的
    	SKBaobeiDetail detail = baobei.getDetail();
    	if(detail == null){
    		detail = new SKBaobeiDetail();
    	}
    	detail.setId(baobei.getId());
    	insert(detail);
	}
    
  

}
